package com.bootdo.acitvity.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class DebugInvocationHandler implements InvocationHandler {
    private Object proxy;

    public DebugInvocationHandler(Object proxy){
        this.proxy = proxy;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] param) throws InvocationTargetException, IllegalAccessException {
        //调用方法之前，我们可以添加自己的操作
        System.out.println("before method " + method.getName());
        Object invoke = method.invoke(proxy, param);

        //调用方法之后，我们同样可以添加自己的操作
        System.out.println("after method " + method.getName());
        return invoke;
    }
}
